﻿using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace Crusades.Map{
  public class Country {
    public string Name { get; set; }
    public Canvas Canvas { get; set; }
    public List<Path> Boundaries { get; set; }
    public Brush DefaultColor { get; set; }
    public long ObjectID{ get; set;}


    public Country(Canvas canvas) {
      Name = canvas.Name;
      Canvas = canvas;
      Boundaries = new List<Path>();
      foreach (var child in canvas.Children) {
        if (child is Path) {
          Boundaries.Add(child as Path);
        }
      }
    }

    public void SetStrokeThickness(double thickness){
      foreach (var child in Canvas.Children){
        if(child is Path){
          var path = child as Path;
          path.StrokeThickness = thickness;
        }
      }
    }

    public Country() {
    }

    public override string ToString() {
      return Name;
    }

    public override bool Equals(object obj) {
      Country c2 = obj as Country;
      return c2 == null ? false : Name == c2.Name;
    }

    public override int GetHashCode() {
      return Name.GetHashCode();
    }


    public void SetBackground(Brush color){
      foreach (Path child in Canvas.Children){
        child.Fill = color;
      }
    }
  }
}